package com.yun.algorithmproblem.leetcode;

import java.util.PriorityQueue;

public class Leetcode3066 {
    public static void main(String[] args) {
        Leetcode3066 obj = new Leetcode3066();
        int[] nums=new int[]{999999999,999999999,999999999};
        int k=1000000000;
        obj.minOperations(nums,k);
    }

    public int minOperations(int[] nums, int k) {
        PriorityQueue<Long> pq=new PriorityQueue<>();
        for (int num : nums) {
            pq.offer((long) num);
        }
        int ans=0;
        while (pq.peek()<k){
            Long a = pq.poll();
            Long b = pq.poll();
            pq.offer(Math.min(a,b)+a+b);
            ans++;
        }
        return ans;
    }
}
